package cn.hchaojie.spring.day01;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.hchaojie.spring.day01.beans.AnnoService;
import cn.hchaojie.spring.day01.beans.AnnotationBean;
import cn.hchaojie.spring.day01.beans.CategoryService;
import cn.hchaojie.spring.day01.beans.PostService;
import cn.hchaojie.spring.day01.beans.UserBean;
import cn.hchaojie.spring.day01.beans.impl.AnnoServiceImpl;

public class Demo4AnnotaionInject {
	ApplicationContext context;
	@Before
	public void init() {
		context = new ClassPathXmlApplicationContext("context-anno.xml");
	}

	@Test
	public void test() {
		CategoryService bean = context.getBean(CategoryService.class);
		System.out.println(bean);
	}

	@Test
	public void test2() {
		PostService bean = context.getBean(PostService.class);
		System.out.println(bean);

		PostService bean2 = context.getBean(PostService.class);
		System.out.println(bean2);
		
		System.out.println(bean == bean2);
	}
}
